Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds QR Code signature feature to default reports #500

Merged
merged 35 commits into from
Dec 3, 2024

Conversation

anderson-mj
Copy link
Contributor

  • Adiciona opção no Report Configuration de qual tipo de assinatura
  • Adiciona tempo de validade em meses pra assinaturas tipo QR Code
  • Adiciona tela de listagem de Reports, com permissão de leitura pra :managers e permissão de edição da validade pra Administradores

@anderson-mj anderson-mj requested a review from JoaoFelipe October 2, 2024 15:12
@anderson-mj anderson-mj self-assigned this Oct 2, 2024
@JoaoFelipe
Copy link
Contributor

JoaoFelipe commented Nov 7, 2024

Deu erro ao executar o rails maintenance:run

$ rails maintenance:run
rails aborted!
NoMethodError: undefined method `prepare_attachments' for main:Object (NoMethodError)

      result = prepare_attachments(notification.execute)
               ^^^^^^^^^^^^^^^^^^^
/home/joao/projects/sapos/lib/tasks/maintenance.rake:38:in `block (3 levels) in <main>'
/home/joao/projects/sapos/lib/tasks/maintenance.rake:37:in `block (2 levels) in <main>'
/home/joao/projects/sapos/lib/tasks/maintenance.rake:8:in `block (2 levels) in <main>'
Tasks: TOP => maintenance:trigger_notifications
(See full trace by running task with --trace)

Outros comentários:

  • Quando o documento expirou e foi removido do sistema, ao invés de retornar "Não encontrado", seria melhor indicar "Documento expirou"
  • Na tela de documentos, seria bom ter o título de cada documento para permitir buscas. Além disso, pode ter a coluna com o hash
  • Faltam testes pro modelo reports

@anderson-mj anderson-mj force-pushed the assertion-pdf-validation branch from 4078ebc to 82be1b3 Compare November 20, 2024 01:38
@JoaoFelipe
Copy link
Contributor

JoaoFelipe commented Nov 21, 2024

O comando maintenance:run continua com erro aqui:

rake aborted!
NoMethodError: undefined method `render_enrollments_grades_report_pdf' for main:Object (NoMethodError)

            render_enrollments_grades_report_pdf(enrollment)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/home/joao/projects/sapos/lib/tasks/maintenance.rake:59:in `block in prepare_attachments'
/home/joao/projects/sapos/lib/tasks/maintenance.rake:53:in `each'
/home/joao/projects/sapos/lib/tasks/maintenance.rake:53:in `prepare_attachments'
/home/joao/projects/sapos/lib/tasks/maintenance.rake:38:in `block (3 levels) in <main>'
/home/joao/.rvm/gems/ruby-3.2.1/gems/activerecord-7.0.8.4/lib/active_record/relation/delegation.rb:88:in `each'
/home/joao/.rvm/gems/ruby-3.2.1/gems/activerecord-7.0.8.4/lib/active_record/relation/delegation.rb:88:in `each'
/home/joao/projects/sapos/lib/tasks/maintenance.rake:37:in `block (2 levels) in <main>'
/home/joao/projects/sapos/lib/tasks/maintenance.rake:8:in `block (2 levels) in <main>'
/home/joao/.rvm/gems/ruby-3.2.1/gems/rake-13.2.1/exe/rake:27:in `<top (required)>'
/home/joao/.rvm/gems/ruby-3.2.1/bin/ruby_executable_hooks:22:in `eval'
/home/joao/.rvm/gems/ruby-3.2.1/bin/ruby_executable_hooks:22:in `<main>'
Tasks: TOP => maintenance:trigger_notifications
(See full trace by running task with --trace)

  • Link de download na página reports não funciona
  • Quando estivermos homologando em produção, temos que verificar como fica a mensagem de documento expirou

@JoaoFelipe
Copy link
Contributor

Erro de autorização

Started GET "/reports" for 127.0.0.1 at 2024-11-21 15:43:03 -0300
Processing by ReportsController#index as HTML
  User Load (0.0ms)  SELECT "users".* FROM "users" WHERE "users"."id" = ? ORDER BY "users"."id" ASC LIMIT ?  [["id", 1], ["LIMIT", 1]]
  ↳ config/initializers/filter_parameter_logging.rb:25:in `call'
  Report Count (0.1ms)  SELECT COUNT(*) FROM "reports"
  ↳ config/initializers/filter_parameter_logging.rb:25:in `call'
  Rendering layout layouts/application.html.erb
  Rendering /home/joao/.rvm/gems/ruby-3.2.1/bundler/gems/active_scaffold-7a61ff721e4e/app/views/active_scaffold_overrides/list.html.erb within layouts/application
  Rendered /home/joao/.rvm/gems/ruby-3.2.1/bundler/gems/active_scaffold-7a61ff721e4e/app/views/active_scaffold_overrides/_list_header.html.erb (Duration: 2.0ms | Allocations: 2079)
  Rendered /home/joao/.rvm/gems/ruby-3.2.1/bundler/gems/active_scaffold-7a61ff721e4e/app/views/active_scaffold_overrides/_list_column_headings.html.erb (Duration: 1.3ms | Allocations: 1923)
  Rendered /home/joao/.rvm/gems/ruby-3.2.1/bundler/gems/active_scaffold-7a61ff721e4e/app/views/active_scaffold_overrides/_messages.html.erb (Duration: 0.4ms | Allocations: 294)
  Rendered /home/joao/.rvm/gems/ruby-3.2.1/bundler/gems/active_scaffold-7a61ff721e4e/app/views/active_scaffold_overrides/_list_messages.html.erb (Duration: 1.8ms | Allocations: 1674)
  Report Load (0.1ms)  SELECT "reports".* FROM "reports" ORDER BY "reports"."id" ASC LIMIT ? OFFSET ?  [["LIMIT", 15], ["OFFSET", 0]]
  ↳ config/initializers/filter_parameter_logging.rb:25:in `call'
  User Load (0.2ms)  SELECT "users".* FROM "users" WHERE "users"."id" = ?  [["id", 1]]
  ↳ config/initializers/filter_parameter_logging.rb:25:in `call'
  CarrierWave::Storage::ActiveRecord::ActiveRecordFile Load (1.0ms)  SELECT carrier_wave_files [SQL Filtered]  [["id", 44], ["LIMIT", 1]]
  ↳ config/initializers/filter_parameter_logging.rb:25:in `call'
  CarrierWave::Storage::ActiveRecord::ActiveRecordFile Load (0.7ms)  SELECT carrier_wave_files [SQL Filtered]  [["id", 47], ["LIMIT", 1]]
  ↳ config/initializers/filter_parameter_logging.rb:25:in `call'
  Rendered collection of /home/joao/.rvm/gems/ruby-3.2.1/bundler/gems/active_scaffold-7a61ff721e4e/app/views/active_scaffold_overrides/_list_record.html.erb [4 times] (Duration: 18.8ms | Allocations: 18388)
  Rendered /home/joao/.rvm/gems/ruby-3.2.1/bundler/gems/active_scaffold-7a61ff721e4e/app/views/active_scaffold_overrides/_list_pagination.html.erb (Duration: 0.5ms | Allocations: 362)
  Rendered /home/joao/.rvm/gems/ruby-3.2.1/bundler/gems/active_scaffold-7a61ff721e4e/app/views/active_scaffold_overrides/_list.html.erb (Duration: 25.5ms | Allocations: 25335)
  Rendered /home/joao/.rvm/gems/ruby-3.2.1/bundler/gems/active_scaffold-7a61ff721e4e/app/views/active_scaffold_overrides/_list_with_header.html.erb (Duration: 28.8ms | Allocations: 29129)
  Rendered /home/joao/.rvm/gems/ruby-3.2.1/bundler/gems/active_scaffold-7a61ff721e4e/app/views/active_scaffold_overrides/list.html.erb within layouts/application (Duration: 29.5ms | Allocations: 29689)
  Student Load (0.1ms)  SELECT "students".* FROM "students" WHERE "students"."user_id" = ? LIMIT ?  [["user_id", 1], ["LIMIT", 1]]
  ↳ config/initializers/filter_parameter_logging.rb:25:in `call'
  Rendered layout layouts/application.html.erb (Duration: 104.9ms | Allocations: 129661)
Completed 500 Internal Server Error in 116ms (Views: 105.5ms | ActiveRecord: 2.7ms | Allocations: 140375)


  Rendering /home/joao/.rvm/gems/ruby-3.2.1/gems/exception_notification-4.5.0/lib/exception_notifier/views/exception_notifier/exception_notification.text.erb
DEPRECATION WARNING: Using a :default format for TimeWithZone#to_s is deprecated. Please use TimeWithZone#to_fs instead. If you fixed all places inside your application that you see this deprecation, you can set `ENV['RAILS_DISABLE_DEPRECATED_TO_S_CONVERSION']` to `"true"` in the `config/application.rb` file before the `Bundler.require` call to fix all the callers outside of your application. (called from render at /home/joao/.rvm/gems/ruby-3.2.1/bundler/gems/active_scaffold-7a61ff721e4e/lib/active_scaffold/extensions/action_view_rendering.rb:200)
  Rendered /home/joao/.rvm/gems/ruby-3.2.1/gems/exception_notification-4.5.0/lib/exception_notifier/views/exception_notifier/_request.text.erb (Duration: 0.6ms | Allocations: 597)
  Rendered /home/joao/.rvm/gems/ruby-3.2.1/gems/exception_notification-4.5.0/lib/exception_notifier/views/exception_notifier/_title.text.erb (Duration: 0.2ms | Allocations: 140)
  Rendered /home/joao/.rvm/gems/ruby-3.2.1/gems/exception_notification-4.5.0/lib/exception_notifier/views/exception_notifier/_session.text.erb (Duration: 0.8ms | Allocations: 1760)
  Rendered /home/joao/.rvm/gems/ruby-3.2.1/gems/exception_notification-4.5.0/lib/exception_notifier/views/exception_notifier/_title.text.erb (Duration: 0.0ms | Allocations: 22)
  Rendered /home/joao/.rvm/gems/ruby-3.2.1/gems/exception_notification-4.5.0/lib/exception_notifier/views/exception_notifier/_environment.text.erb (Duration: 2.0ms | Allocations: 2197)
  Rendered /home/joao/.rvm/gems/ruby-3.2.1/gems/exception_notification-4.5.0/lib/exception_notifier/views/exception_notifier/_title.text.erb (Duration: 0.0ms | Allocations: 22)
  Rendered /home/joao/.rvm/gems/ruby-3.2.1/gems/exception_notification-4.5.0/lib/exception_notifier/views/exception_notifier/_backtrace.text.erb (Duration: 0.3ms | Allocations: 120)
  Rendered /home/joao/.rvm/gems/ruby-3.2.1/gems/exception_notification-4.5.0/lib/exception_notifier/views/exception_notifier/_data.text.erb (Duration: 0.6ms | Allocations: 1549)
  Rendered /home/joao/.rvm/gems/ruby-3.2.1/gems/exception_notification-4.5.0/lib/exception_notifier/views/exception_notifier/_title.text.erb (Duration: 0.0ms | Allocations: 22)
  Rendered /home/joao/.rvm/gems/ruby-3.2.1/gems/exception_notification-4.5.0/lib/exception_notifier/views/exception_notifier/exception_notification.text.erb (Duration: 7.2ms | Allocations: 9317)
#exception_notification: processed outbound mail in 15.2ms
firefox /home/joao/projects/sapos/tmp/letter_opener/1732214583_3410974_a0e8329/plain.html
Delivered mail [email protected] (256.5ms)
Date: Thu, 21 Nov 2024 15:43:03 -0300
From: SAPOS Exception Notifier <[email protected]>
To: [email protected]
Message-ID: <[email protected]>
Subject: [SAPOS: Error] reports#index (CanCan::AuthorizationNotPerformed)
 "This action failed the check_authorization because it ...
Mime-Version: 1.0
Content-Type: text/plain;
 charset=UTF-8
Content-Transfer-Encoding: 7bit

A CanCan::AuthorizationNotPerformed occurred in reports#index:

  This action failed the check_authorization because it does not authorize_resource. Add skip_authorization_check to bypass this check.



-------------------------------
Request:
-------------------------------

  * URL        : http://127.0.0.1:3000/reports
  * HTTP Method: GET
  * IP address : 127.0.0.1
  * Parameters : {"controller"=>"reports", "action"=>"index"}
  * Timestamp  : 21/11/2024 15:43
  * Server : BOOK-TGVLUAKK8J
    * Rails root : /home/joao/projects/sapos
  * Process: 80781

-------------------------------
Session:
-------------------------------

  * session id: "c356aaed833fba68f13e2b8298a63b95"
  * data: {"warden.user.user.key"=>[[1], "$2a$10$.puvBOXvvCWfql999PGeYe"],
   "_csrf_token"=>"XKrrx_g5DyXacY2dgHpyK5J6BkYQHIDpZC0v6KaInb0",
   "input_device_type"=>"MOUSE",
   "hover_supported"=>true}

-------------------------------
Environment:
-------------------------------

  * GATEWAY_INTERFACE                                       : CGI/1.2
    * HTTP_ACCEPT                                             : text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
    * HTTP_ACCEPT_ENCODING                                    : gzip, deflate, br, zstd
    * HTTP_ACCEPT_LANGUAGE                                    : en-GB,en;q=0.9,en-US;q=0.8,pt-BR;q=0.7,pt-PT;q=0.6,pt;q=0.5
    * HTTP_CONNECTION                                         : keep-alive
    * HTTP_COOKIE                                             : BetterErrors-has-used-console=true; _sapos_session=c356aaed833fba68f13e2b8298a63b95; BetterErrors-2.10.1-CSRF-Token=ff80029b-acbe-4a3c-a0c7-87b4907b4f8e
    * HTTP_HOST                                               : 127.0.0.1:3000
    * HTTP_REFERER                                            : http://127.0.0.1:3000/pendencies
    * HTTP_SEC_CH_UA                                          : "Microsoft Edge";v="131", "Chromium";v="131", "Not_A Brand";v="24"
    * HTTP_SEC_CH_UA_MOBILE                                   : ?0
    * HTTP_SEC_CH_UA_PLATFORM                                 : "Windows"
    * HTTP_SEC_FETCH_DEST                                     : document
    * HTTP_SEC_FETCH_MODE                                     : navigate
    * HTTP_SEC_FETCH_SITE                                     : same-origin
    * HTTP_SEC_FETCH_USER                                     : ?1
    * HTTP_UPGRADE_INSECURE_REQUESTS                          : 1
    * HTTP_USER_AGENT                                         : Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 Edg/131.0.0.0
    * HTTP_VERSION                                            : HTTP/1.1
    * ORIGINAL_FULLPATH                                       : /reports
    * ORIGINAL_SCRIPT_NAME                                    :
    * PATH_INFO                                               : /reports
    * QUERY_STRING                                            :
    * REMOTE_ADDR                                             : 127.0.0.1
    * REQUEST_METHOD                                          : GET
    * REQUEST_PATH                                            : /reports
    * REQUEST_URI                                             : /reports
    * ROUTES_18080_SCRIPT_NAME                                :
    * SCRIPT_NAME                                             :
    * SERVER_NAME                                             : 127.0.0.1
    * SERVER_PORT                                             : 3000
    * SERVER_PROTOCOL                                         : HTTP/1.1
    * SERVER_SOFTWARE                                         : puma 6.4.2 The Eagle of Durango
    * action_controller.instance                              : #<ReportsController:0x00007fe36378c5a0>
    * action_dispatch.authenticated_encrypted_cookie_salt     : [FILTERED]
    * action_dispatch.authorized_host                         : 127.0.0.1
    * action_dispatch.backtrace_cleaner                       : #<Rails::BacktraceCleaner:0x00007fe3bd3d88a0>
    * action_dispatch.content_security_policy                 :
    * action_dispatch.content_security_policy_nonce_directives:
    * action_dispatch.content_security_policy_nonce_generator :
    * action_dispatch.content_security_policy_report_only     : false
    * action_dispatch.cookies_digest                          :
    * action_dispatch.cookies_rotations                       : #<ActiveSupport::Messages::RotationConfiguration:0x00007fe3bed6c6b8>
    * action_dispatch.cookies_same_site_protection            : #<Proc:0x00007fe3b748dc10 /home/joao/.rvm/gems/ruby-3.2.1/gems/railties-7.0.8.4/lib/rails/application.rb:609>
    * action_dispatch.cookies_serializer                      : json
    * action_dispatch.encrypted_cookie_cipher                 : [FILTERED]
    * action_dispatch.encrypted_cookie_salt                   : [FILTERED]
    * action_dispatch.encrypted_signed_cookie_salt            : [FILTERED]
    * action_dispatch.http_auth_salt                          : [FILTERED]
    * action_dispatch.key_generator                           : #<ActiveSupport::CachingKeyGenerator:0x00007fe3bd1f33f0>
    * action_dispatch.log_rescued_responses                   : true
    * action_dispatch.logger                                  : #<ActiveSupport::Logger:0x00007fe3bc5f42e8>
    * action_dispatch.parameter_filter                        : [:password, :passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn]
    * action_dispatch.permissions_policy                      : #<ActionDispatch::PermissionsPolicy:0x00007fe3bc8d13f8>
    * action_dispatch.redirect_filter                         : []
    * action_dispatch.remote_ip                               : 127.0.0.1
    * action_dispatch.request.accepts                         : [#<Mime::Type:0x00007fe3bdd62088 @synonyms=["application/xhtml+xml"], @symbol=:html, @string="text/html", @hash=1597390731516728352>, #<Mime::Type:0x00007fe36374ddf0 @synonyms=[], @symbol=nil, @string="image/avif", @hash=-4034355347249533712>, #<Mime::Type:0x00007fe36374dda0 @synonyms=[], @symbol=ni...
    * action_dispatch.request.content_type                    :
    * action_dispatch.request.flash_hash                      : #<ActionDispatch::Flash::FlashHash:0x00007fe3b591c828>
    * action_dispatch.request.formats                         : [#<Mime::Type:0x00007fe3bdd62088 @synonyms=["application/xhtml+xml"], @symbol=:html, @string="text/html", @hash=1597390731516728352>]
    * action_dispatch.request.parameters                      : {"controller"=>"reports", "action"=>"index"}
    * action_dispatch.request.path_parameters                 : {:controller=>"reports", :action=>"index"}
    * action_dispatch.request.query_parameters                : {}
    * action_dispatch.request.request_parameters              : {}
    * action_dispatch.request_id                              : a81e62ba-3a81-4011-afae-b96b2af0b044
    * action_dispatch.routes                                  : #<ActionDispatch::Routing::RouteSet:0x00007fe3bd462140>
    * action_dispatch.secret_key_base                         : [FILTERED]
    * action_dispatch.show_detailed_exceptions                : true
    * action_dispatch.show_exceptions                         : true
    * action_dispatch.signed_cookie_digest                    :
    * action_dispatch.signed_cookie_salt                      : [FILTERED]
    * action_dispatch.use_authenticated_cookie_encryption     : [FILTERED]
    * action_dispatch.use_cookies_with_metadata               : true
    * exception_notifier.exception_data                       : {:user_id=>1, :user_name=>"admin", :user_email=>"[email protected]", :url=>"http://127.0.0.1:3000/reports"}
    * puma.config                                             : #<Puma::Configuration:0x00007fe3bc7d2178>
    * puma.request_body_wait                                  : 0.004808999598026276
    * puma.socket                                             : #<TCPSocket:0x00007fe3b7473838>
    * rack.after_reply                                        : []
    * rack.errors                                             : #<IO:0x00007fe3c3848f10>
    * rack.hijack                                             : #<Puma::Client:0x00007fe3bdf1b910>
    * rack.hijack?                                            : true
    * rack.input                                              : #<Puma::NullIO:0x00007fe3bc079b60>
    * rack.multiprocess                                       : false
    * rack.multithread                                        : true
    * rack.request.cookie_hash                                : {"BetterErrors-has-used-console"=>"true", "_sapos_session"=>"c356aaed833fba68f13e2b8298a63b95", "BetterErrors-2.10.1-CSRF-Token"=>"[FILTERED]"}
    * rack.request.cookie_string                              : BetterErrors-has-used-console=true; _sapos_session=c356aaed833fba68f13e2b8298a63b95; BetterErrors-2.10.1-CSRF-Token=ff80029b-acbe-4a3c-a0c7-87b4907b4f8e
    * rack.request.query_hash                                 : {}
    * rack.request.query_string                               :
    * rack.run_once                                           : false
    * rack.session                                            : #<ActionDispatch::Request::Session:0x00007fe3b54ca2e8>
    * rack.session.options                                    : #<ActionDispatch::Request::Session::Options:0x00007fe3b5527218>
    * rack.session.record                                     : #<ActiveRecord::SessionStore::Session:0x00007fe3bf3285c0>
    * rack.tempfiles                                          : []
    * rack.url_scheme                                         : http
    * rack.version                                            : [1, 6]
    * warden                                                  : Warden::Proxy:292320 @config={:default_scope=>:user, :scope_defaults=>{}, :default_strategies=>{:user=>[:rememberable, :database_authenticatable]}, :intercept_401=>false, :failure_app=>#<Devise::Delegator:0x00007fe3bd00c618>}

-------------------------------
Data:
-------------------------------

  * data: {:user_id=>1,
   :user_name=>"admin",
   :user_email=>"[email protected]",
   :url=>"http://127.0.0.1:3000/reports"}




CanCan::AuthorizationNotPerformed - This action failed the check_authorization because it does not authorize_resource. Add skip_authorization_check to bypass this check.:

Since there is no EDITOR or BETTER_ERRORS_EDITOR environment variable, using Textmate by default.
Started POST "/__better_errors/c9849b82016f1be8/variables" for 127.0.0.1 at 2024-11-21 15:43:03 -0300

@leomurta leomurta merged commit 961ab31 into develop Dec 3, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants